import AsyncStorage from '@react-native-community/async-storage';
import PushNotificationIOS from "@react-native-community/push-notification-ios";

const type = `fcm/token`;

const handel = (token:string) => {
    AsyncStorage.setItem(type, token);
}

export const init = async () => {
    const token = await getToken();
    if (!token) {
        PushNotificationIOS.addEventListener(
            'register',handel
        )
    }
}

export const getToken = async (): Promise<string> => {
    return await AsyncStorage.getItem(type) as string;
}

